import { renderTag, NTagType } from '@/utils/common'
import { DataTableColumn } from 'naive-ui'
import { useCodeStore } from '@/store/modules/code'
import { Dict } from '@/enums'

const codeStore = useCodeStore()

export const basicColumns: Array<DataTableColumn<BaseUserVO>> = [
    {
        key: 'id',
        width: 200,
        title: '编号'
    },
    {
        key: 'username',
        title: '账号'
    },
    {
        key: 'nickname',
        title: '昵称'
    },
    {
        key: 'roles',
        title: '角色',
        width: 300,
        ellipsis: true,
        render(row){
            return row.roles.map(ele => ele.name).join('，')
        }
    },
    {
        key: 'gender',
        title: '性别',
        render(row){
            return renderTag(codeStore.getName(Dict.Gender, row.gender))
        }
    },
    {
        key: 'avatar',
        title: '头像'
    },
    {
        key: 'status',
        title: '状态',
        render(row){
            let type: NTagType = row.status == '0' ? 'error' : undefined
            return renderTag(codeStore.getName(Dict.Status, row.status), type)
        }
    }
]